*********************************************************
* Bankert, A., Del Ponte, A., Huddy, L. (2022)          *
* Partisanship in Times of Crisis - Evidence from Italy *
* Political Science Research and Methods                *
* Replication Do-File: Main Text                        *
*********************************************************

*****************************************************
* Table 1 - Distribution of partisan identity items *
*****************************************************
sum Partisan_ID if totalwaves==5
tab Q25_01_W1 if totalwaves==5
tab Q25_03_W1 if totalwaves==5
tab Q25_04_W1 if totalwaves==5
tab Q25_05_W1 if totalwaves==5
tab Q25_06_W1 if totalwaves==5
tab Q25_07_W1 if totalwaves==5
tab Q25_08_W1 if totalwaves==5
tab Q25_09_W1 if totalwaves==5
tab Q25_10_W1 if totalwaves==5
alpha Q25_01_W1 Q25_03_W1 Q25_04_W1 Q25_05_W1 Q25_06_W1 Q25_07_W1 Q25_08_W1 Q25_09_W1 Q25_10_W1 if totalwaves==5

***********************************************************
* Table 2 - Determinants of in-party vote among partisans *
***********************************************************
*(1) Partisan ID
logit VotedInparty_SenateorChamber_W5 c.Partisan_ID##i.rightWing_W1 c.Partisan_ID##i.leftWing_W1 Education01 Age_Cat01 Employment01 Sample if totalwaves==5 & PartyID_W1!=12 & Turnout_W5==1

*(2) Partisan Strength
logit VotedInparty_SenateorChamber_W5 c.PID_Strength##i.rightWing_W1 c.PID_Strength##i.leftWing_W1 Education01 Age_Cat01 Employment01 Sample if totalwaves==5 & PartyID_W1!=12 & Turnout_W5==1

****************************************************************************************************
* Figure 1 - In-party voting across partisan identity strength for partisans on the left and right *
****************************************************************************************************
logit VotedInparty_SenateorChamber_W5 c.Partisan_ID##i.rightWing_W1 c.Partisan_ID##i.leftWing_W1 Education01 Age_Cat01 Employment01 Sample if totalwaves==5 & PartyID_W1!=12 & Turnout_W5==1
margins, at(Partisan_ID =(0(0.1)1) Employment==1 Sample==0 rightWing_W1==0 leftWing_W1==1 ) atmeans 
marginsplot, recast(line) recastci(rarea) title("Partisans on the Left") xtitle("Partisan Identity Strength") ytitle("In-Party Voting") ylabel(0(0.2)1) xlabel (0(0.2)1)
graph save Figure1_Left.gph, replace

logit VotedInparty_SenateorChamber_W5 c.Partisan_ID##i.rightWing_W1 c.Partisan_ID##i.leftWing_W1 Education01 Age_Cat01 Employment01 Sample if totalwaves==5 & PartyID_W1!=12 & Turnout_W5==1
margins, at(Partisan_ID =(0(0.1)1) Employment==1 Sample==0 rightWing_W1==1 leftWing_W1==0 ) atmeans 
marginsplot, recast(line) recastci(rarea) title("Partisans on the Right") xtitle("Partisan Identity Strength") ytitle("In-Party Voting") ylabel(0(0.2)1) xlabel (0(0.2)1) 
graph save Figure1_Right.gph, replace

grc1leg Figure1_Left.gph Figure1_Right.gph, ycommon


************************************************************
* Table 3 - Determinants of voting for M5S among partisans *
************************************************************
*(1) Partisan ID
logit Grillo_ChamberorSenate c.Partisan_ID##i.rightWing_W1 c.Partisan_ID##i.leftWing_W1 Education01 Age_Cat01 Employment01 Sample if totalwaves==5 & Turnout_W5==1

*(2) Partisan Strength
logit Grillo_ChamberorSenate c.PID_Strength##i.rightWing_W1 c.PID_Strength##i.leftWing_W1 Education01 Age_Cat01 Employment01  Sample if totalwaves==5 & Turnout_W5==1

****************************************************************************************************
* Figure 2 - Voting for M5S by partisan identity strength among left-wing and right-wing partisans *
****************************************************************************************************
logit Grillo_ChamberorSenate c.Partisan_ID##i.rightWing_W1 c.Partisan_ID##i.leftWing_W1  Education01 Age_Cat01 Employment01 Sample if totalwaves==5 & Turnout_W5==1
margins, at(Partisan_ID =(0(0.1)1) rightWing_W1 == 0 leftWing_W1 == 1 Employment==1 ) atmeans
marginsplot, recast(line) recastci(rarea) title("Parties on the Left") xtitle("Partisan Identity Strength") ytitle("Vote for M5S") legend(off)
graph save Figure2_Left.gph, replace

logit Grillo_ChamberorSenate c.Partisan_ID##i.rightWing_W1 c.Partisan_ID##i.leftWing_W1  Education01 Age_Cat01 Employment01 Sample if totalwaves==5 & Turnout_W5==1
margins, at(Partisan_ID =(0(0.1)1) rightWing_W1==1 leftWing_W1==0 Employment==1 ) atmeans
marginsplot, recast(line) recastci(rarea) title("Parties on the Right") xtitle("Partisan Identity Strength") ytitle("Vote for M5S") legend(off)
graph save Figure2_Right.gph, replace

grc1leg Figure2_Left.gph Figure2_Right.gph, ycommon

*********************************************************************
* Table 4 - Determinants of positive Grillo ratings among partisans *
*********************************************************************
*(1)Partisan ID
reg Grillo_W5 c.Partisan_ID##i.rightWing_W1 c.Partisan_ID##i.leftWing_W1 Education01 Age_Cat01 Employment01 Sample if totalwaves==5

*(2) Partisan Strength
reg Grillo_W5 c.PID_Strength##i.rightWing_W1 c.PID_Strength##i.leftWing_W1 Education01 Age_Cat01 Employment01  Sample if totalwaves==5

*********************************************************************************************************
* Table 5 - Analysis of voting for M5S and adjusted ratings of Grillo among partisans and non-partisans *
*********************************************************************************************************
*(1) Voting
logit Grillo_ChamberorSenate_all noparty Education01 Age_Cat01 Employment01 Sample if totalwaves==5 & Turnout_W5==1
*(2) Interaction with Education
logit Grillo_ChamberorSenate_all noparty##c.Education01 Age_Cat01 Employment01 Sample if totalwaves==5 & Turnout_W5==1
*(3)Rating
reg NewGrillo_CorrectedforNoParty_W5 noparty Education01 Age_Cat01 Employment01 Sample if totalwaves==5
*(4)Interaction with Education
reg NewGrillo_CorrectedforNoParty_W5 noparty##c.Education01 Education01 Age_Cat01 Employment01 Sample if totalwaves==5

//Note. How many non-partisans voted? 89%, compared to 95% partisans. Actual turnout (population) was 75.19%.
sort noparty
by noparty: tab Turnout_W5

// % of people who voted in 2013 elections (Completed panel)
tab Turnout_W5
tab Turnout_W5 if Sample==0 //CATI
tab Turnout_W5 if Sample==1 //CAWI

// partisan strength
tab PID_Strength if totalwaves==5
corr PID_Strength Partisan_ID if totalwaves==5
